/*
 * @Description: 
 * @Author: Sang Hao
 * @Date: 2021-09-15 17:08:57
 * @LastEditTime: 2021-11-09 11:49:14
 * @LastEditors: Sang Hao
 */
#include "lidar_slam/models/cloud_filter/pass_filter.hpp"

namespace lidar_slam {
bool PassFilter::SetFilterParam(std::string field_name, float limit_min, float limit_max) {
	pass_through_filter_.setFilterFieldName(field_name);
	pass_through_filter_.setFilterLimits(limit_min, limit_max);
	return true;
}

PassFilter::PassFilter(const YAML::Node& config_node) {
	std::string field_name = config_node["field_name"].as<std::string>();
	float limit_min = config_node["limit_min"].as<float>();
	float limit_max = config_node["limit_max"].as<float>();
	SetFilterParam(field_name, limit_min, limit_max);
}

PassFilter::PassFilter(std::string field_name, float limit_min, float limit_max) {
	SetFilterParam(field_name, limit_min, limit_max);
}

bool PassFilter::Filter(const CloudData::CLOUD_PTR& input_cloud_ptr, 
		CloudData::CLOUD_PTR& filter_cloud_ptr) {
	
	pass_through_filter_.setInputCloud(input_cloud_ptr);
	pass_through_filter_.filter(*filter_cloud_ptr);
	
	return true;
}
}